<?php

require_once 'Pipes/User/Credentials.php';

class Pipes_User_Credentials_Factory
{
	public function fromSession() {
		if (isset($_SESSION['Pipes']['User']['Credentials']['identity'])) {
			$identity = $_SESSION['Pipes']['User']['Credentials']['identity'];
			$isValid = $_SESSION['Pipes']['User']['Credentials']['isValid'];
		} else {
			$identity = 'anonymous';
			$isValid = true;
		}
		return new Pipes_User_Credentials($identity, $isValid);
	}
}
